home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
UTILREEN
/
EGA2RAM.LZH
/
EGA2RAM.ASM
next >
Wrap
Assembly Source File
|
1988-03-13
|
12KB
|
317 lines
; EGA²RAM
;
; EGA²RAM is a (memory-resident) device driver which copies IBM's EGA
; BIOS code to RAM. Since the IBM EGA is an 8-bit card, copying the
; code to 16-bit RAM results in a significant improvement in graphics
; performance. This operation will NOT, of course, affect programs
; which write directly to display memory; and note that the display
; memory itself is not moved, only the BIOS code.
;
; EXE2BIN must be run on EGA²RAM.EXE to convert it to .SYS format.
; Then put a line in your CONFIG.SYS like "DEVICE = EGA2RAM.SYS" .
;
;
; THIS PROGRAM WAS WRITTEN BY
; GREG ROELOFS
; UNIVERSITY OF CHICAGO
; 11 MARCH 1988
;
;
; Most recent revisions: 13 March 1988
;
;
CSEG Segment
Assume CS:CSEG, DS:NOTHING, ES:NOTHING
Org 0000h ; .SYS files start here
; Device header
; -------------
HeaderPtr dw 0FFFFh, 0FFFFh ; pointer to next device driver
Attrib dw 8000h ; character device, not block
StrategyPtr dw Offset Strategy ; routine to store request hdr
InterruptPtr dw Offset Interrupt ; routine to process request
DriverName db "EGA²RAM$" ; name of this driver
; Strategy routine
; ----------------
Strategy: MOV CS:RequestOffset, BX ; store offset and segment of
MOV CS:RequestSegment, ES ; request header...
RETF ; ...then return to DOS
RequestAddr Label DWord ;
RequestOffset dw 0000 ; request header stuff goes here
RequestSegment dw 0000 ;
; Interrupt routine
; -----------------
Interrupt: PUSH AX ;
PUSH BX ;
PUSH CX ;
PUSH DX ;
PUSH DS ; save registers and flags
PUSH ES ;
PUSH DI ;
PUSH SI ;
PUSHF ;
LDS BX, DWord Ptr RequestAddr ; set DS:BX to req. hdr.
MOV AL, [BX + 2] ; get command code from header
OR AL, AL ; set flags
JNZ NotINIT ; if not zero (INIT), exit
JMP Initialize ; if zero, go do our thing
NotINIT: MOV AH, 1 ; 'done' bit in return status
MOV [BX + 3], AX ; send return status back
POPF ;
POP SI ;
POP DI ;
POP ES ;
POP DS ; restore registers and flags
POP DX ;
POP CX ;
POP BX ;
POP AX ;
RETF ; ... and leave
; EGA shadow BIOS goes here
; -------------------------
db "EGA²RAM: Copyright (c) 1988 by Greg Roelofs"
EGABIOS Label Byte
db 055h, 0AAh, 020h, 0EBh, 028h
db '2400'
db '6277356 (C)COPYRIGHT IBM 1984'
db '9/13/84'
db 3942h dup (0) ; total length = 3960h + 0Fh
; bytes so we can align on
; a segment boundary
; Throw-away data
; ---------------
IntrptTable Label Word ; offsets in low memory for
dw 10h*4 ; INT 10h,
dw 1Fh*4 ; INT 1Fh, and
dw 43h*4 ; INT 43h
ErrorFlag db 00 ; gets set to FFh if can't load
ErrorHeader dw 810Ch ; indicates Gen. Failure to INIT
SuccessHeader dw 0100h ; indicates INIT was successful
EndCodeAddr Label DWord ;
EndOffset dw Offset IntrptTable ; if success, end of BIOS area
; Initialization code: print message, load BIOS, revector vectors
; ----------------------------------------------------------------
Initialize: MOV AH, 3 ; BIOS function to read cursor
XOR BH, BH ; position (page 0) - using
INT 10h ; original EGA ROM BIOS
PUSH DX ; save current position on stack
MOV AH, 8 ; BIOS function to read char/
INT 10h ; attribute at current position
PUSH AX ; will save current screen color
PUSH CS ; load ES with segment
POP ES ; we're in
MOV BP, Offset InitMsg ; address of string
MOV DX, 011Dh ; (row,col) to print string
MOV CX, 8 ; 8 lines to print
TitleLoop: PUSH CX ; save count
MOV CX, 51 ; number of characters per line
XOR BH, BH ; page 0
MOV AX, 1303h ; write string with
INT 10h ; individual attributes
INC DH ; next row
ADD BP, 2*51 ; next batch of characters
POP CX ; get count...
LOOP TitleLoop ; ...and go back for next line
; Compare first 2Dh bytes of EGA BIOS to make sure IBM's
; ------------------------------------------------------
CLD ; forward direction for strings
MOV DI, Offset EGABIOS ; ES still points to the current
MOV DX, 0C000h ; segment (from above)
MOV DS, DX ; point DS:SI to EGA ROM segment
XOR SI, SI ; (C000:0000h)
MOV CX, 2Dh ; number of bytes to compare
REPE CMPSB ; do the comparison
JCXZ LoadBIOS ; string compares OK: IBM EGA
MOV ErrorFlag, 0FFh ; set error flag
MOV BX, Offset EGABIOS ; truncate since aborting: put
MOV Word Ptr EndCodeAddr, BX ; it in temporary variable
MOV BP, Offset ErrorMsg ; address of error message: not
JMP SHORT FinalMessage ; an EGA BIOS ==> not installed
; EGA BIOS is correct version: begin copy operation to segment boundary
; ----------------------------------------------------------------------
LoadBIOS: MOV AX, Offset EGABIOS + 16 ; get offset into current
MOV CL, 4 ; segment, round up to nearest
SHR AX, CL ; multiple of 16, and divide
MOV BX, ES ; by 16 (shift right 4 bits)
ADD AX, BX ; to get number of 16-byte
MOV ES, AX ; paragraphs to add to ES; DS
; is still okay
XOR DI, DI ; reset source and destination
XOR SI, SI ; offsets to 0 (segment bdry)
MOV CX, 1CB0h ; number of WORDS to move
REP MOVSW ; do it
; Copy of BIOS now resides in RAM: fix up vectors, etc.
; ------------------------------------------------------
XOR DX, DX ; clear DX
MOV DS, DX ; set DS to low memory
MOV BX, DS:[04A8h] ; get offset of SAVE_TBL
MOV ES:[BX + 2], ES ; replace C000h with new segment
CLI ; disable interrupts while busy
MOV DS:[04AAh], ES ; replace SAVE_TBL segment
MOV CX, 3 ; need to change 3 interrupts
MOV SI, Offset IntrptTable ; location of table for INT vecs
FixInterrupts: MOV BX, CS:[SI] ; DX = offset into low-mem table
MOV [BX + 2], ES ; re-vector segment only
ADD SI, 2 ; ready for next interrupt
LOOP FixInterrupts ; do it
STI ; re-enable interrupts
; Print final message (note: using shadow BIOS, if load was successful)
; ----------------------------------------------------------------------
MOV BP, Offset FinalMsg ; successful load
FinalMessage: PUSH CS ; reset ES to the current
POP ES ; segment
MOV DX, 071Fh ; (row,col) to print string
MOV CX, 42 ; number of characters in string
XOR BH, BH ; page 0
MOV AX, 1303h ; write string with
INT 10h ; individual attributes
MOV BP, Offset BlankLine ; address of string
POP BX ; retrieve old attribute (BH)
XCHG BH, BL ; put it in BL
XOR BH, BH ; page 0
POP DX ; retrieve old cursor position
MOV CX, 11 ; space, 9 LFs, CR
MOV AX, 1301h ; write string with
INT 10h ; group attribute, move cursor
; Set up exit code for INIT data area and return to DOS control
; -------------------------------------------------------------
MOV AX, SuccessHeader ; 'done' bit in return status
CMP ErrorFlag, 0 ; was it really successful?
JE ReturnInfo ; yes
MOV AX, ErrorHeader ; no
ReturnInfo: LDS BX, DWord Ptr RequestAddr ; set DS:BX to req. hdr.
MOV [BX + 3], AX ; send return status back
MOV AX, EndOffset ; get end-of-code offset...
MOV [BX + 14], AX ; ...and give to DOS...
MOV [BX + 16], ES ; ...as well as EOC segment
POPF ;
POP SI ;
POP DI ;
POP ES ;
POP DS ; restore registers and flags
POP DX ;
POP CX ;
POP BX ;
POP AX ;
RETF ; ... and leave
; More data (installation message)
; --------------------------------
.RADIX 16
InitMsg db "╔",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"╤",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"╤",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"╗",0E
db "║",0E," ",07,"V",0C,"e",0C,"r",0C,"s",0C,"i",0C,"o",0C
db "n",0C," ",0C,"1",0C,".",0C,"0",0C,"0",0C," ",0E,"│",0E
db " ",0E," ",0E," ",0E," ",0E," ",0E,"E",0Dh,"G",0Dh,"A",0Dh
db "²",0E,"R",09,"A",09,"M",09," ",0E," ",0E," ",0E," ",0E
db " ",0E,"│",0E," ",0E," ",0C,"1",0C,"3",0C," ",0C,"M",0C
db "a",0C,"r",0C,"c",0C,"h",0C," ",0C,"1",0C,"9",0C,"8",0C
db "8",0C," ",07,"║",0E
db "╟",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"┴",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"┴",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"╢",0E
db "║",0E," ",07,"A",02,"n",02,"o",02,"t",02,"h",02,"e",02
db "r",02," ",02,"n",02,"i",02,"f",02,"t",02,"y",02," ",02
db "p",02,"r",02,"o",02,"d",02,"u",02,"c",02,"t",02," ",02
db "f",02,"r",02,"o",02,"m",02," ",02,"t",02,"h",02,"e",02
db " ",02,"f",02,"o",02,"l",02,"k",02,"s",02," ",02,"a",02
db "t",02," ",02,"A",0A,"w",0A,"e",0A,"s",0A,"o",0A,"m",0A
db "e",0A," ",07,"║",0E
db "║",0E," ",07,"C",0A,"o",0A,"m",0A,"p",0A,"u",0A,"t",0A
db "i",0A,"n",0A,"g",0A," ",0A,"C",0A,"o",0A,"m",0A,"p",0A
db "a",0A,"n",0A,"y",0A,",",02," ",02,"a",02," ",02,"d",02
db "i",02,"v",02,"i",02,"s",02,"i",02,"o",02,"n",02," ",02
db "o",02,"f",02," ",02,"D",0A,"E",0A," ",0A,"E",0A,"n",0A
db "t",0A,"e",0A,"r",0A,"p",0A,"r",0A,"i",0A,"s",0A,"e",0A
db "s",0A," ",07,"║",0E
db "╟",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E,"─",0E
db "─",0E,"─",0E,"╢",0E
db "║",0E," ",07,"C",03,"o",03,"p",03,"y",03,"i",03,"n",03
db "g",03," ",03,"1",03,"4",03,",",03,"6",03,"8",03,"8",03
db " ",03,"b",03,"y",03,"t",03,"e",03,"s",03," ",03,"o",03
db "f",03," ",03,"E",03,"G",03,"A",03," ",03,"B",03,"I",03
db "O",03,"S",03," ",03,"t",03,"o",03," ",03,"R",03,"A",03
db "M",03,".",03,".",03,".",03," ",03," ",03," ",03," ",03
db " ",03," ",07,"║",0E
db "╚",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E,"═",0E
db "═",0E,"═",0E,"╝",0E
ErrorMsg db "N",03,"o",03,"n",03,"-",03,"I",03,"B",03
db "M",03," ",03,"E",03,"G",03,"A",03," ",03,"B",03,"I",03
db "O",03,"S",03,":",03," ",03," ",03,"i",03,"n",03,"s",03
db "t",03,"a",03,"l",03,"l",03,"a",03,"t",03,"i",03,"o",03
db "n",03," ",03,"a",03,"b",03,"o",03,"r",03,"t",03,"e",03
db "d",03,".",03," ",03," ",03
FinalMsg db "I",03,"n",03,"s",03,"t",03,"a",03,"l",03
db "l",03,"a",03,"t",03,"i",03,"o",03,"n",03," ",03,"c",03
db "o",03,"m",03,"p",03,"l",03,"e",03,"t",03,"e",03,",",03
db " ",03,"y",03,"o",03,"u",03," ",03,"b",03,"e",03,"t",03
db "c",03,"h",03,"a",03,".",03," ",03," ",03," ",03," ",03
db " ",03," ",03," ",03," ",03
BlankLine db " ", 0A, 0A, 0A, 0A, 0A, 0A, 0A, 0A, 0A, 0Dh
CSEG ENDS ;
END ; denotes entry point